The need for graphics clipping arises in most systems that display graphics. An example of such a system is the IBM Graphical Data Display Manager (GDDM) program produced by IBM Corporation (GDDM and IBM are trademarks of International Business Machines Corporation). The GDDM program runs on a system comprising a host computer to which many terminals are attached. The host computer stores and processes graphics and then sends it to the appropriate terminal for display. These operations of the system are performed under the control of the GDDM program. One of the functions a program such as the GDDM program must perform is graphics clipping.
There are a number of known ways of clipping graphics areas defined by their border to so called viewing windows or viewports, e.g. Sutherland-Hodgman Algorithm, Weiler-Atherton Algorithm. A discussion of these techniques can be found in the book `Fundamentals of Interactive Computer Graphics` by J. D. Foley and A. Van Dam, pages 450 to 457 published in 1982 by Addison Wesley.
The Sutherland-Hodgman Algorithm works on the principle of treating the viewing window as being composed of a collection of infinitely extending clip lines. The task of clipping a subject polygon against a single infinitely extending clip line is relatively straight forward. By collecting the results of successive clippings against these clip lines the portion of the polygon to be displayed may be determined. A particular problem that occurs concerns detecting how to plot the so called `closure lines` between points on the boundary of the polygon being clipped where it intersects the viewing window. The standard Sutherland-Hodgman produces extraneous closure lines that must be removed by additional processing steps. The need for this extra processing to eliminate the extraneous edges reduces the efficiency of the clipping.
An alternative is to use the Weiler-Atherton Algorithm. This algorithm operates by tracking around the border of the subject polygon in the clockwise direction until an intersection with the viewing window is encountered. If the edge is entering the viewing window, the algorithm then proceeds along the subject polygon edge. If the edge is leaving the viewing window, then the algorithm makes a right turn and follows the edge of the viewing window. In either case, the intersection is remembered and used to ensure that all paths are tracked exactly once. While the Weiler-Atherton Algorithm does not suffer from the problem of producing extraneous closure lines it is disadvantageously more complex than the Sutherland-Hodgman Algorithm.